package interfacedemo1;

public class DataInterImpl1 implements DataInter {
    private Students[] students;
    public DataInterImpl1(Students[] students) {
        this.students = students;
    }

    @Override//重写打印所有学生成绩
    public void printAllScore() {
        for (int i = 0; i < students.length; i++) {
            Students s = students[i];
            System.out.println(s.getName()+" " +s.getSex()+" "+s.getScore());
        }

    }

    @Override//重写打印平均分
    public void printAvgScore() {
        double sum = 0;
        for (int i = 0; i < students.length; i++) {
            Students s = students[i];
            sum += s.getScore();
        }
        System.out.println("平均分是：" + sum/students.length);
    }
}
